#ifndef __NONAME_VECTOR_H__
#define __NONAME_VECTOR_H__

#define NONAME_LIB_USE

#include <ntifs.h>
#include "nm_mem.h"

#define DEFAULT_INIT_VECTOR	32

template <class T>
class kvector {

public:
	kvector();
	kvector(ULONG Size, ULONG Step);
	void Release();
	ULONG Size() { return m_ItemCount; }
	T& operator[] (ULONG Index);

private:
	T *m_Vector;
	ULONG m_ItemCount;
	ULONG m_Step;

};

template <class T>
kvector<T>::kvector()
{
	m_Step = DEFAULT_INIT_VECTOR;
	m_ItemCount = DEFAULT_INIT_VECTOR;

	m_Vector = new T[m_ItemCount];
}

template <class T>
T& kvector<T>::operator[]( ULONG Index )
{
	ULONG Count;
	T *tmp;
	ULONG i;

	if (Index >= m_ItemCount) {

		Count = m_ItemCount;
		while (Index >= Count) {

			Count += m_Step;
		}

		tmp = new T[Count];

		for (i = 0; i < m_ItemCount; i++){

			tmp[i] = m_Vector[i];
		}

		m_ItemCount = Count;

		delete[] m_Vector;
		m_Vector = tmp;
	}

	return m_Vector[Index];
}

template <class T>
void kvector<T>::Release()
{
	delete[] m_Vector;
}

template <class T>
kvector<T>::kvector( ULONG Size, ULONG Step )
{
	m_Step = Step;
	m_ItemCount = Size;

	m_Vector = new T[m_ItemCount];
}



#endif